<script setup>
import BackLink from "@/components/BackLink/index.vue"
import {useRoute, useRouter} from "vue-router";
import UserBaseInfo from "@/components/UserBaseInfo/index.vue";
import {getCertificateListApi, getInternshipListApi, getStuDetailsApi} from "@/api/school.js";
import {formatDate} from "../../../../utils/index.js";
const router = useRouter()
const route = useRoute()
const state = reactive({
  studentInfo: {},
  tableData: [],
  queryParams: {
    pageNum: 1,
    pageSize: 8,
    stuId: '',
  },
  total: 0,
})

const showDia1 = ref(false)

const handleBack = () => {
  router.go(-1)
}

const getDataList = async () => {
  const res = await getInternshipListApi(state.queryParams)
  if (res.code == 200) {
    state.tableData = res.rows
    state.total = res.total
  }
}

const getStuDetails = async () => {
  const res = await getStuDetailsApi({id: state.queryParams.stuId})
  if (res.code == 200) {
    state.studentInfo = res.data
  }
}

const handleDetails = (item) => {
  router.push({
    path: '/baseData/comprehensiveIn/InternshipExperience/details',
    query: {
      stuId:item.stuId,
      id: item.id,
      isShow:1
    }
  })
}

onMounted(() => {
  const id = route.query.id
  state.queryParams.stuId = id
  getDataList()
  getStuDetails()
})
</script>

<template>
  <div class="outBox">
    <el-card>
      <BackLink/>
      <div class="form-box">
        <UserBaseInfo :student-info="state.studentInfo"/>
        <div class="form-textArea">
          <div class="form-item">
            <div class="form-name">实习经历</div>
            <div class="text-items">
              <div class="text-item" v-for="item in state.tableData">
                <div class="tit">{{item.shipTitle}}</div>
                <div class="bottom">
                  <div class="time">{{formatDate(item.createTime)}}</div>
                  <div class="check">
                    <el-button type="primary" link @click="handleDetails(item)">查看详情</el-button>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="pageBox">
          <pagination
              v-show="state.total > 0"
              :total="state.total"
              v-model:page="state.queryParams.pageNum"
              v-model:limit="state.queryParams.pageSize"
              @pagination="getDataList()"
              layout="'total, prev, pager, next, jumper'"
          />
        </div>

        <div class="center-btns">
          <el-button  @click="handleBack" type="primary">返回</el-button>
        </div>
      </div>
    </el-card>

  </div>
</template>

<style scoped lang="scss">
.text-items{
  padding: 20px;
  display: grid;
  justify-content: space-between;
  grid-template-columns: repeat(2, 550px);
  .text-item{
    margin-bottom: 20px;
  }
  .tit{
    font-size: 22px;
    margin-bottom: 5px;
  }
  .bottom{
    display: flex;
    justify-content: space-between;
    .time{
      color: #827e7d;
    }
  }
}
.center-btns{
  display: flex;
  justify-content: center;
  margin-top: 20px;
}
.form-textArea{
  border: 1px solid #e5e5e5;
  min-height:400px;
  :deep(.el-textarea){
    --el-input-border-color:#fff !important;
    --el-input-focus-border:#fff !important;
    --el-input-hover-border-color:#fff !important;
    --el-input-focus-border-color:#fff !important;

  }
}
.form-box{
  .form-name{
    background: #f1f7ff;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100px;
    font-weight: bold;
    border-right: 1px solid #e5e5e5;
  }
  .form-line{
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border: 1px solid #e5e5e5;
    margin-bottom: 20px;
    .form-item{
      display: flex;
      align-items: center;

      .form-cont{
        width: calc(100% - 100px);
        :deep(.el-input){
          --el-input-border-color:#fff !important;
          --el-input-focus-border:#fff !important;
          --el-input-focus-border-color:#fff !important;
        }
      }
    }
  }
}
</style>
